function init(){
    imgPreview();
    changeStatus();
    changeShopProductNum();
}

function changeStatus(){
    $('.input-shop-flg input.checkbox').change(function(){
        var url = $(this).closest('form').attr('action');
        var value = $(this).is(':checked')==true?1:0;
        var name = $(this).attr('data-name');
        var shop = {id: $(this).parents('tr').attr('data-id')};
        shop[name] = value;
        changeState(url, {shop: shop});
    });

    $('td.input-shop-active-flg input.checkbox').change(function(){
        var url = $(this).closest('form').attr('action');
        var shop = {
            id: $(this).parents('tr').attr('data-id'),
            user_id: $(this).parents('tr').attr('data-user-id')
        };
        changeState(url, {shop: shop});
    });
}

function getRegisteringShop(url){
    if(document.URL != data.href){
        window.location = data.href;
    }
}

function changeShopProductNum(){
    $('.btn-shop-block-product-count').click(function(){
        var form = $(this).closest('form');
        var id = $(this).parents('tr').attr('data-id');
        var num = $(this).parents('td').find('.input-shop-block-product-count').val();
        var post = {'id': id, 'num': num};
        changeState(form.attr('action-setting'), {shop:post});
    });
}